package org.steven0lisa.typhoon.ui;

import java.util.List;

import org.steven0lisa.typhoon.bean.TyphoonStatus;

import com.baidu.mapapi.map.Geometry;
import com.baidu.mapapi.map.Graphic;
import com.baidu.mapapi.map.GraphicsOverlay;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.Symbol;
import com.baidu.platform.comapi.basestruct.GeoPoint;

public class TyphoonPathOverlay extends GraphicsOverlay {

	public TyphoonPathOverlay(MapView arg0) {
		super(arg0);
	}

	public void drawPath(List<TyphoonStatus> statusList) {
		// 构建线
		Geometry lineGeometry = new Geometry();
		// 设定折线点坐标
		GeoPoint[] linePoints = new GeoPoint[statusList.size()];
		for (int i = 0; i < linePoints.length; i++) {
			TyphoonStatus status = statusList.get(i);
			linePoints[i] = status.getPoint();
		}
		lineGeometry.setPolyLine(linePoints);
		// 设定样式
		Symbol lineSymbol = new Symbol();
		Symbol.Color lineColor = lineSymbol.new Color();
		lineColor.red = 255;
		lineColor.green = 0;
		lineColor.blue = 0;
		lineColor.alpha = 255;
		lineSymbol.setLineSymbol(lineColor, 3);
		// 生成Graphic对象
		Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);

		setData(lineGraphic);
	}

}
